package com.sk.bilibili.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sk.bilibili.bean.Forward;
import com.sk.bilibili.other.R;
import com.sk.bilibili.service.ForwardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
* @author 邵康
* @date 2021/11/24 19:32
*/
@CrossOrigin
@RestController
@RequestMapping("/forward")
@Api(tags = "转发")
public class ForwardController {

    @Autowired
    private ForwardService forwardService;
//
//    @ApiOperation("转发动态动态  会转发原内容  待转发动态id,内容必须  会更新动态")
//    @GetMapping("/forward")
//    public R<Void> forward(Integer id, String content, HttpSession session){
//        return forwardService.forward(id,content,session);
//    }

    @ApiOperation("添加转发内容：类型，类型Id,内容 必须")
    @PostMapping("/add")
    public R<Void> add(@RequestBody Forward forward){
        return forwardService.add(forward);
    }

    @ApiOperation("deleteRes")
    @GetMapping("/delete")
    public R<Void> delete(Integer id){
        return forwardService.delete(id);
    }

    @ApiOperation("update")
    @PostMapping("/update")
    public R<Void> update(@RequestBody Forward forward){
        return forwardService.update(forward);
    }

    @ApiOperation("pageSearch")
    @GetMapping("/page")
    public R<IPage<Forward>> page( @RequestParam(defaultValue = "1") Integer page,
                                @RequestParam(defaultValue = "10") Integer size){
        return forwardService.page(page,size);
    }

}
